package com.yh.javabean;

import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import java.util.ArrayList;

public interface one {
    @Select("select * from user")
    @Results(id = "u_r", value = {
            /* 定义主键列*/
            @Result(id = true, property = "uid", column = "uid"),
            @Result(property = "uusername", column = "uusername"),
            @Result(property = "upassword", column = "upassword"),
            /* 对于一对一查询 property代表对应的存储数据的对象   column代表查询条件对应的值 一般使用主键
             * one 代表当前查询结果类型为一个数据(一对一查询)
             * one标签用于定义一对一查询相关属性
             * select 代表当前一对一查询调用的其他查询结果 使用mapper全路径.方法名的形式进行调用
             * fetchType = FetchType.LAZY 代表开启懒加载
             * */
            @Result(property = "role", column = "uid", one = @One(select = "mapper.RoleMapper.selectByUid", fetchType = FetchType.LAZY))
    })
    ArrayList<User> selectAll();
}

